//限时抢购 
var t;
var currentTime = "";
var domainLocal = ".lenovomobile.com";
var Common = {
	processLogin : function() {
		$.ajax({
					url : HOST + "/login/login_info.jhtml",
					type : "POST",
					data : {},
					dataType : "json",
					cache : false,
					success : function(result) {
						if (result.v) {
							loginSuccessTagOp();
						} else {
							 $("#personal-center-box").hide();
							 $("#login-center-box").show();
						}
					}
				});
	},
	processCart : function() {
		$.ajax({
			url : HOST + "/store/cart/cart_total.jhtml",
			type : "POST",
			data : {},
			dataType : "json",
			cache : false,
			success : function(result) {
				$("#i_cart_total").html(result.count);
			}
		});
	},
	getToken : function() {
		var token = "";
		$.ajax({
			url : HOST + "/token/token.jhtml",
			type : "POST",
			data : {},
			dataType : "json",
			cache : false,
			async: false,
			success : function(result) {
				token = result.token;
			}
		});
		return token;
	},
	processFeast:function(){
		var paths = ["/","/com.shenqi.web.shop/","/zt/"];
		var currPathname = window.location.pathname;
		var show_feast = true;
		for(var i in paths){
			if(paths[i] == currPathname){
				show_feast = false;
				break;
			}
			if(i > 1 && currPathname.indexOf(paths[i]) != -1){
				show_feast = false;
				break;
			}
		}
		if(show_feast){
			yrredbegin = typeof(yrredbegin) == "undefined" ? 0 : yrredbegin;
			yrredend = typeof(yrredend) == "undefined" ? 0 : yrredend;
			hdredbegin = typeof(hdredbegin) == "undefined" ? 0 : hdredbegin;
			hdredend = typeof(hdredend) == "undefined" ? 0 : hdredend;
			if(yrredbegin > 0 && yrredend > 0 && hdredbegin > 0 && hdredend > 0){
				$.get(HOST+"/time.jhtml", null, 
						function (data, status) {
							currentTime = parseInt(data);
							if(yrredbegin <= currentTime && yrredend >= currentTime){
								$("body").addClass("white-theme");
								$("<link>").attr({rel:"stylesheet",type:"text/css",href: IMAGEURL +"/css/fesitval.css"}).appendTo("head");
								$(".global-header .wrapper").append("<div class=\"countdown\"></div>");
								oneYearTimeFun(yrredend-currentTime, "countdown");
							} else if(hdredbegin <= currentTime && hdredend >= currentTime){
								$("<link>").attr({rel:"stylesheet",type:"text/css",href: IMAGEURL +"/css/fesitval1.css"}).appendTo("head");
								var year_red_html = "<span id=\"year_red_picture\" class=\"small-red-paper\">200元现金券</span>";
								year_red_html = year_red_html + "<div class=\"countdown-box\"><p>距活动结束还有</p><div class=\"countdown\"></div></div>";
								$(".global-header .wrapper").append(year_red_html);
								oneYearTimeFun(hdredend-currentTime, "countdown");
								$("#year_red_picture").click(function(){
									yearRedShow();
								});
								if("/store/" == currPathname || "/com.shenqi.web.shop/store/" == currPathname){
									var cookie_value = getcookie('time.red.200') || "";
									if(cookie_value != 1){
										yearRedShow();
									}
								}
						}
				});
			}
		}
	},
	getSubHtml:function(){
		$.get(HOST+'/avd/getsubhtml.html',function(data){
			$(data).appendTo('.global-header .sub-product-nav');
		});
	}
};
var Message = {
	tipsYB : function(text) {
		if ($(".detail-layer").length > 0) {
			$(".detail-layer p span").html(text);
			$(".detail-layer,.layer-bg").fadeIn();
		} else {
			var html = "";
			if($(".layer-bg").length > 0){
				$(".layer-bg").show();
			} else{
				html = "<div class=\"layer-bg\"></div>";
			}
			html += "<div  class=\"detail-layer\"><span class=\"close\"></span><p><span>"
					+ text + "</span></p></div>";
			$("body").append(html);
		}
		t = setTimeout("$('.detail-layer,.layer-bg').fadeOut();", 3000);
	},
	tipsPS : function(text) {
		if ($(".detail-layer").length > 0) {
			$(".detail-layer p span").html(text);
			$(".detail-layer,.layer-bg").fadeIn();
		} else {
			var html = "";
			if($(".layer-bg").length > 0){
				$(".layer-bg").show();
			} else{
				html = "<div class=\"layer-bg\"></div>";
			}
			html += "<div  class=\"detail-layer remind-succuss\"><span class=\"close\"></span><p><span>"
					+ text + "</span></p></div>";
			$("body").append(html);
		}
		t = setTimeout("$('.detail-layer,.layer-bg').fadeOut();", 3000);
	},
	tipsAB : function(text) {
		if ($(".detail-layer").length > 0) {
			$(".xiajia").html(text);
			$(".detail-layer,.layer-bg").fadeIn();
		} else {
			var html = "";
			if($(".layer-bg").length > 0){
				$(".layer-bg").show();
			} else{
				html = "<div class=\"layer-bg\"></div>";
			}
			html += "<div  class=\"detail-layer\"><span class=\"close\"></span><p><span class=\"xiajia\">"
					+ text + "</span></p></div>";
			$("body").append(html);
		}
		t = setTimeout("$('.detail-layer,.layer-bg').fadeOut();", 2000);
	}
};
/*!
 * jquery.base64.js 0.1 - https://github.com/yckart/jquery.base64.js
 * Base64 en & -decoding
 *
 * Copyright (c) 2012 Yannick Albert (http://yckart.com)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php).
 * 2013/02/10
 **/
;(function($){
    $.base64 = $.fn.base64 = function (dir, input) {
        var publ = {},
            self = this,
            b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
        // http://phpjs.org/functions/base64_encode/
        publ.encode = function (data) {
            data = !(self instanceof $) ? data : self.is(':input') ? self.val() : self.text();
            data = unescape(encodeURIComponent( data ));

            if (data === '') return;
            var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
                ac = 0,
                enc = "",
                tmp_arr = [];

            if (!data) return data;

            do { // pack three octets into four hexets
                o1 = data.charCodeAt(i++);
                o2 = data.charCodeAt(i++);
                o3 = data.charCodeAt(i++);

                bits = o1 << 16 | o2 << 8 | o3;

                h1 = bits >> 18 & 0x3f;
                h2 = bits >> 12 & 0x3f;
                h3 = bits >> 6 & 0x3f;
                h4 = bits & 0x3f;

                // use hexets to index into b64, and append result to encoded string
                tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
            } while (i < data.length);

            enc = tmp_arr.join('');

            var r = data.length % 3;

            return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3);
        };

        // http://phpjs.org/functions/base64_decode/
        publ.decode = function (data) {
            data = !(self instanceof $) ? data : self.is(':input') ? self.val() : self.text();

            var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
                ac = 0,
                dec = "",
                tmp_arr = [];

            if (!data) return data;

            data += '';

            do { // unpack four hexets into three octets using index points in b64
                h1 = b64.indexOf(data.charAt(i++));
                h2 = b64.indexOf(data.charAt(i++));
                h3 = b64.indexOf(data.charAt(i++));
                h4 = b64.indexOf(data.charAt(i++));

                bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;

                o1 = bits >> 16 & 0xff;
                o2 = bits >> 8 & 0xff;
                o3 = bits & 0xff;

                if (h3 == 64) {
                    tmp_arr[ac++] = String.fromCharCode(o1);
                } else if (h4 == 64) {
                    tmp_arr[ac++] = String.fromCharCode(o1, o2);
                } else {
                    tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
                }
            } while (i < data.length);

            dec = tmp_arr.join('');

            return decodeURIComponent(escape( dec ));
        };

        return input ? publ[dir](input) : dir ? null : publ;
    };
}(jQuery));
function loginiframe() {
	var lhref = encodeURIComponent(window.location.href);
	var ctx = $.base64('encode', lhref)
	var browser =HOST.replace("http://","");
	var url = LENOVOHOST
			+ "/wauthen3/wauth/jsp/ilogin.jsp?lenovoid.action=uilogin&lenovoid.realm="
			+ REALM
			+ "&lenovoid.uinfo=username"
			+ "&lenovoid.ctx="
			+ ctx
			+ "&lenovoid.cb="
			+ HOST
			+ "/login/logincallback.jhtml"
			+ "&lenovoid.source=browser:"+browser+"&lenovoid.vp=0&intcmp=lenovoID_log&display=";
	$("#lenovoidiframe").attr("src", url);
	$("#logintitle").html("登录");
	$(".layer-bg").show();
	$("#loginiframe").show();
}
function registeriframe() {
	var lhref = encodeURIComponent(window.location.href);
	var ctx = $.base64('encode', lhref)
	 var browser =HOST.replace("http://","");
	var url = LENOVOHOST
			+ "/wauthen3/wauth/jsp/ilogin.jsp?lenovoid.iframestate=register&lenovoid.action=uilogin&lenovoid.realm="
			+ REALM
			+ "&lenovoid.uinfo=username"
			+ "&lenovoid.ctx="
			+ ctx
			+ "&lenovoid.cb="
			+ HOST
			+ "/login/logincallback.jhtml"
			+ "&lenovoid.source=browser:"+browser+"&lenovoid.vp=0&intcmp=lenovoID_log&display=";
	$("#lenovoidiframe").attr("src", url);
	$("#logintitle").html("注册");
	$(".layer-bg").show();
	$("#loginiframe").show();
}
function logincloseiframe() {
	$(".layer-bg").hide();
	$("#loginiframe").hide();
	$("#logintitle").html("");
}
function getCookie(name) {
    var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
    if (arr != null) return arr[2]; return null;
}
function loginSuccessTagOp(){
	var code = getCookie('SHOP_niceName');
	var name = decodeURIComponent(code || "");
	$(".personal-avator .name").html(name);
	$("#ztnicename").html(name);
	$("#personal-center-box").show();
	$("#login-center-box").hide();
	$('.global-top #personal-center-box').on({
		'mouseenter' : function() {
			$(this).addClass('has-layer')
		},
		'mouseleave' : function() {
			$(this).removeClass('has-layer')
		}
	}, '.personal-inner');
	$('.topic-header #personal-center-box').on({
		'mouseenter' : function() {
			$(this).addClass('has-layer')
		},
		'mouseleave' : function() {
			$(this).removeClass('has-layer')
		}
	});
	var motozpath = "/zt/motozqxg";
	var currPathname = window.location.pathname;
	if(currPathname.indexOf(motozpath) != -1){
		getlike();
	}
}

document.domain = location.host.replace(/^.*?([^.]+\.[^.]+)$/g,'$1');
var LID = {};
LID.Module = {
	iTitle : function(sTitle) {
		
		$('.jsPopupTitle').text(sTitle);
	},
	iHeight : function(sHeight) {
		
		$('.jsIframe').css('height', sHeight + 'px');
	},
	iLoginQQ : function(sQuery) {
	
		 window.location.href=
		 'https://passport.lenovo.com/wauthen3/thirdOauth?thirdName=qqsns&'+sQuery;
	},
	iLoginSina : function(sQuery) {
	
		 window.location.href=
		 'https://passport.lenovo.com/wauthen3/thirdOauth?thirdName=sina&'+sQuery;
	},
	iLpsust : function(sLpsust) {
		$.ajax({
			url : HOST + '/login/logingetinfo.jhtml',
			type : 'POST',
			async : false,
			cache : false,
			dataType : 'json',
			data : {
				"lenovoid.wust" : sLpsust
			},
			success : function(data) {
				if (data != null && data.status == 1) {
					logincloseiframe();
					loginSuccessTagOp();
					/*添加小能咨询参数修改的处理 added by liuxiaolong begin*/
					if(typeof(web_chat_param) != "undefined"){
						web_chat_param.uid = getcookie('SHOP_id') || "";
						web_chat_param.uname = getcookie('SHOP_niceName') || "";
					}
					/*添加小能咨询参数修改的处理 added by liuxiaolong end*/
					/*周年庆红包领取弹层*/
					var paths = ["/","/com.shenqi.web.shop/","/zt/"];
					var currPathname = window.location.pathname;
					var show_feast = true;
					for(var i in paths){
						if(paths[i] == currPathname){
							show_feast = false;
							break;
						}
						if(i > 1 && currPathname.indexOf(paths[i]) != -1){
							show_feast = false;
							break;
						}
					}
					var cookie_value = getcookie('time.red.200') || "";
					if(show_feast && cookie_value != 1 && hdredbegin <= currentTime && hdredend >= currentTime && yrredend < currentTime){
						yearRedShow();
					}
					if(typeof(motozkp) != "undefined" && motozkp){
						window.location.reload();
					}
				}
			}
		});
		
	},
	iRedirect : function(sUrl) {
		window.open(sUrl, '_blank'); 
	}
};
$.dialog = function(options) {
	var settings = {
		width : 320,
		height : "auto",
		modal : true,
		text : "确认要删除该商品吗？",
		ok : "确定",
		cancel : "取消",
		onShow : null,
		onClose : null,
		onOk : null,
		onCancel : null,
		autoClose : null
	};
	$.extend(settings, options);
	if (settings.content == null) {
		return false;
	}
	var $dialog = $('<div class="pop-layer delete-layer"></div>');
	var $dialogHead = $('<div class="pop-layer-head"></div>');

	var $dialogTitle;
	var $dialogClose = $('<a href="#" class="close">关闭</a>');
	var $dialogContent;
	var $dialogContentText;
	var $dialogBottom;
	var $dialogOk;
	var $dialogCancel;
	var $dialogOverlay;
	if (settings.title != null) {
		$dialogTitle = $('<h3>确认提示</h3>').appendTo($dialogHead);
	}
	$dialogClose.appendTo($dialogHead);
	$dialogContent = $('<div class="pop-layer-bd"></div>');

	if (settings.content != null) {
		$dialogContentText = $('<div class="delete-txt"><span class="wrong-icon">'
				+ settings.content + '</span></div>');
	}
	$dialogContentText.appendTo($dialogContent);
	$dialogBottom = $('<div class="pop-layer-footer clearfix"></div>');

	if (settings.cancel != null) {
		$dialogCancel = $(
				'<a href="javaScript://" class="cancle-btn">' + settings.cancel
						+ '</a>').appendTo($dialogBottom);
	}
	if (settings.ok != null) {
		$dialogOk = $(
				'<input type="button" value="' + settings.ok
						+ '" class="sub-btn"/>').appendTo($dialogBottom);
	}
	$dialog.append($dialogHead).append($dialogContent).append($dialogBottom);
	$dialog.appendTo("body");

	if (settings.modal) {
		$dialogOverlay = $('<div class="layer-bg"><\/div>')
				.insertAfter($dialog);
	}
	var dialogX;
	var dialogY;
	if (settings.title != null) {
		$dialogTitle.html(settings.title);
	}
	$dialog.css({
		"width" : settings.width,
		"height" : settings.height,
		"margin-left" : -parseInt(settings.width / 2),
		"z-index" : 10000
	});
	if ($dialogTitle != null) {
		$dialogTitle.mousedown(function(event) {
			$dialog.css({
				"z-index" : zIndex++
			});
			var offset = $(this).offset();
			if (!window.XMLHttpRequest) {
				dialogX = event.clientX - offset.left;
				dialogY = event.clientY - offset.top;
			} else {
				dialogX = event.pageX - offset.left;
				dialogY = event.pageY - offset.top;
			}
			$("body").bind("mousemove", function(event) {
				$dialog.css({
					"top" : event.clientY - dialogY,
					"left" : event.clientX - dialogX,
					"margin" : 0
				});
			});
			return false;
		}).mouseup(function() {
			$("body").unbind("mousemove");
			return false;
		});
	}
	if (settings.autoClose) {
		setTimeout(function() {
			dialogClose();
		}, 3000);
	}
	if ($dialogClose != null) {
		$dialogClose.click(function() {
			dialogClose();
			return false;
		});
	}
	if ($dialogOk != null) {
		$dialogOk.click(function() {
			if (settings.onOk && typeof settings.onOk == "function") {
				if (settings.onOk($dialog) != false) {
					dialogClose();
				}
			} else {
				dialogClose();
			}
			return false;
		});
	}
	if ($dialogCancel != null) {
		$dialogCancel.click(function() {
			if (settings.onCancel && typeof settings.onCancel == "function") {
				if (settings.onCancel($dialog) != false) {
					dialogClose();
				}
			} else {
				dialogClose();
			}
			return false;
		});
	}
	function dialogShow() {
		if (settings.onShow && typeof settings.onShow == "function") {

			if (settings.onShow($dialog) != false) {
				$dialog.show();
				$dialogOverlay.show();
			}
		} else {
			$dialog.show();
			$dialogOverlay.show();
		}
	}
	function dialogClose() {
		if (settings.onClose && typeof settings.onClose == "function") {
			if (settings.onClose($dialog) != false) {
				$dialogOverlay.remove();
				$dialog.remove();
			}
		} else {
			$dialogOverlay.remove();
			$dialog.remove();
		}
	}
	return $dialog;
};

function LenovoIdSyncLoginState(lenovoid_wust) {
	$.ajax({
		url : HOST + '/login/singlelogin.jhtml',
		type : 'POST',
		async : false,
		cache : false,
		dataType : 'json',
		data : {
			wust : lenovoid_wust
		},
		success : function(data) {
			if (data != null && data.status == 1) {
				loginSuccessTagOp();
			} 
		}
	});
}
function getQueryString(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
	var r = window.location.search.substr(1).match(reg);
	if (r != null)
		return unescape(r[2]);
	return null;
}
// 添加cookie
var addCookie = function(cookieName, cookieValue, cookieHours) {
	var str = cookieName + "=" + unescape(cookieValue);
	if (cookieHours > 0) {
		var date = new Date();
		var ms = cookieHours * 3600 * 1000;
		date.setTime(date.getTime() + ms);
		str += "; expires=" + date.toGMTString();
	}
	str += "; domain="+domainLocal+"; path=/";
	document.cookie = str;
};

function getcookie(cookiename){
	var cookiestring = document.cookie;
	var start = cookiestring.indexOf(cookiename + '=');
	if (start == -1)
	return   null;
	start += cookiename.length   +   1;
	var end = cookiestring.indexOf( "; ",   start);
	if (end == -1) return unescape(cookiestring.substring(start));
	return unescape(cookiestring.substring(start, end));
}

function fadeShow(obj,h,time){
	$(window).scroll(function(){
		if($(window).scrollTop() > h){
			$(obj).fadeIn(time);
		}else{
			$(obj).fadeOut(time);
		}
	});
	
	$(obj).find(".goTop").click(function(){
		$('body,html').animate({scrollTop:0},time);
		return false;
	});
}
var the_ssl = 0;
var oneYearTime;
function oneYearTimeFun(the_time, objid){
	the_ssl = the_time;
	if(the_ssl > 0){ 
		var the_H=Math.floor((the_time)/3600); 
		var the_M=Math.floor((the_time-the_H*3600)/60); 
		var the_S=(the_time-the_H*3600)%60; 
		html = ""; 
		if(the_H!=0) html += "<span>"+(the_H < 10 ? "0"+the_H : the_H)+"</span><i>:</i>"; 
		else html += "<span>00</span><i>:</i>"; 
		if(the_H!=0 || the_M!=0) html += "<span>"+(the_M < 10 ? "0"+the_M : the_M)+"</span><i>:</i>"; 
		else html += "<span>00</span><i>:</i>";
		if(the_S < 10) html += "<span>"+"0"+the_S+"</span>";
		else html += "<span>"+the_S+"</span>";
		$("."+objid).html(html); 
		the_ssl--; 
		oneYearTime=window.setTimeout("oneYearTimeFun("+the_ssl+", '"+objid+"');", 1000);
	}else{
		window.clearInterval(oneYearTime);
		window.location.reload();
	} 
}

var _adwq = _adwq || [];
$(document).ready(function() {
	Common.processLogin();
	Common.processCart();
	Common.processFeast();
	Common.getSubHtml();
	$("body").on("click", ".detail-layer .close", function() {
		$(".layer-bg,.detail-layer").hide();
		window.clearTimeout(t);
	})
	jQuery(function($) {
		$.getScript(LENOVOHOST
				+ "/wauthen3/synCookie.jhtml?lenovoid_realm=" + REALM);
	});
	/*var cid = getQueryString("cid");*/
	var ltinfo = getQueryString("LTINFO");
	var euid = getQueryString("euid");
	/*
	if ("" != cid && cid != null && cid != 'undefined') {
		cid = encodeURIComponent(cid);
		addCookie("source_cid", cid, 720);
	}*/
	if ("" != ltinfo && ltinfo != null && ltinfo != 'undefined') {
		ltinfo = encodeURIComponent(ltinfo);
		addCookie("LTINFO", ltinfo, 720);
	}
	if ("" != euid && euid != null && euid != 'undefined') {
		euid = encodeURIComponent(euid);
		addCookie("euid", euid, 720);
	}
	
	var cookie_value = getcookie('source_cid');
	if(cookie_value == 'sqgc1303' ){
	   
	   _adwq.push(['_setAccount', 'x77w4']);
	   _adwq.push(['_setDomainName', domainLocal]);
	   _adwq.push(['_trackPageview']);
		
		var adw = document.createElement('script');
		adw.type = 'text/javascript';
		adw.async = true;
		adw.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://s') + '.emarbox.com/js/adw.js';
		var s = document.getElementsByTagName('script')[0];
		s.parentNode.insertBefore(adw, s);
	}
	/* 共用底部语言切换效果 */
	$('.copyright .language').hover(function(){
		$(this).addClass('hover-layer');
	},function(){
		$(this).removeClass('hover-layer');
	})
	
	//bottom weixin img
	$('.col-links .weixin').on({
		'mouseenter':function(){
			$(this).find('img').show();
		},
		'mouseleave':function(){
			$(this).find('img').delay(300).hide(0);
		}
	});
	
	var timer = null;
	$('.nav-wrap .item').hover(function(){
		clearInterval(timer);
		$(this).addClass('cur').siblings().removeClass('cur');
		$('.sub-product-nav').find('.product-list').hide().eq($(this).index()).show();
		$('.sub-product-nav').slideDown(200);
	},function(){
		timer = setInterval(function(){
			$('.sub-product-nav').slideUp(200);
			$('.nav-wrap .item').removeClass('cur');
		},300)
	});
		
		
	$('.sub-product-nav').hover(function(){
		clearInterval(timer);
	},function(){
		timer = setInterval(function(){
			$('.sub-product-nav').slideUp(200);
			$('.nav-wrap .item').removeClass('cur');
		},300)
	});
});

/*周年庆*/
var $redClose;
function yearRedShow(){
	var $redPage = $('<div class="zn-red-paper" style="display: block;"></div>');
	$redClose = $('<span class="close"></span>');
	var $redLineone = $('<p>请于4月22日24:00前使用哦</p>');
	var $redYuyueBtn = $('<a href="javascript:;">立即领取</a>');
	$redPage.append($redClose);
	$redPage.append($redLineone);
	$redPage.append($redYuyueBtn);
	var $overlay = $('<div class="layer-bg" style="display: block;"></div>');
	$overlay.appendTo("body");
	$redPage.appendTo("body");
	$redClose.click(function() {
		$overlay.remove();
		$redPage.remove();
		return false;
	});
	$redYuyueBtn.click(function() {
		getYearRed();
		return false;
	});
}

function getYearRed(){
	$.ajax({
		type: "post",
		url: HOST+"/store/coupon/get.jhtml",
		data: {"activityId":22} ,
		success: function(data){
			if(data != null){
				var msg=data.msg;
				var content=data.content;
				$redClose.click();
				if(msg == "win"){
					addCookie("time.red.200",1,48);
					var coupons=data.coupons;
					redPage01(coupons.price, coupons.endtime);
				}else if(msg=="nologin"){
					$redClose.click();
					loginiframe();
				}else if(msg=="againwin"){
					addCookie("time.red.200",1,48);
					redPage02(content);
				}else if(msg=="end"){
					alert("此活动已过期了哦~");
				}else if(msg=="nostart"){
					alert("很抱歉，该活动还未开始。");
				}else if(msg=="nowin"){
					alert("没抢到，请继续！");
				}
			}
		},
		dataType: "json"
	});
}

function redPage01(price, endtime){
	var $redPage = $('<div class="reservation-layer-mod reservation-red successed" style="display: block;"></div>');
	var redClose = $('<span class="close"></span>');
	var $redLineone = $('<p class="line-one">'+price+'元优惠券领取成功</p>');
	var $redText1 = $('<p class="txt1">优惠券过期时间：'+endtime+'</p>');
	var $redText2 = $('<p class="txt2">购买Z1标配版或Z1套餐可用</p>');
	var $redYuyueBtn = $('<a id="zukyear_clickAlertBuyNow" href="'+HOST+'/store/2.html" class="yuyue-btn">立即购买</a>');
	var $redText3 = $('<p class="txt3">优惠券可在填写订单时选取使用，立减'+price+'元！</p>');
	$redPage.append(redClose);
	$redPage.append($redLineone);
	$redPage.append($redText1);
	$redPage.append($redText2);
	$redPage.append($redYuyueBtn);
	$redPage.append($redText3);
	var $overlay = $('<div class="layer-bg" style="display: block;"></div>');
	$overlay.appendTo("body");
	$redPage.appendTo("body");
	redClose.click(function() {
		$overlay.remove();
		$redPage.remove();
		return false;
	});
Avatar.push(['register', document.getElementById("zukyear_clickAlertBuyNow"), {parser:clickBtnOrLink, args:["zukyear_clickAlertBuyNow", "优惠劵领取弹框立即购买"]}]);
}
function redPage02(price){
	var $redPage = $('<div class="reservation-layer-mod reservation-red" style="display: block;"></div>');
	var redClose =$('<span class="close"></span>'); 
	var $redLineone =$('<p class="line-one">您已领过优惠券，快去下单吧！</p>'); 
	var $redYuyueBtn = $('<a id="zukyear_clickAlertBuyNow" class="yuyue-btn" href="'+HOST+'/store/2.html">立即购买</a>');
	var $redText3 = $('<p class="txt3">优惠券可在填写订单时选取使用，立减'+price+'元！</p>');
	$redPage.append(redClose);
	$redPage.append($redLineone);
	$redPage.append($redYuyueBtn);
	$redPage.append($redText3);
	var $overlay = $('<div class="layer-bg" style="display: block;"></div>');
	$overlay.appendTo("body");
	$redPage.appendTo("body");
	redClose.click(function() {
		$overlay.remove();
		$redPage.remove();
		return false;
	});
Avatar.push(['register', document.getElementById("zukyear_clickAlertBuyNow"), {parser:clickBtnOrLink, args:["zukyear_clickAlertBuyNow", "优惠劵领取弹框立即购买"]}]);
}

function clickProductList(evt, target, btnTag, label){
	var flag = '',
	params = {};
	if(evt.target.getAttribute('index') == null){
		flag = evt.target.parentNode.getAttribute('index');
		params["cnt"]=evt.target.parentNode.getAttribute('href');
		if(flag == null ){
			flag = evt.target.parentNode.parentNode.getAttribute('index');
			params["cnt"]=evt.target.parentNode.parentNode.getAttribute('href');
			if(evt.target.parentNode.parentNode.getAttribute('index') == null ){
				flag = evt.target.parentNode.parentNode.parentNode.getAttribute('index');
				params["cnt"]=evt.target.parentNode.parentNode.parentNode.getAttribute('href');
			}else{
				flag = evt.target.parentNode.parentNode.getAttribute('index');
				params["cnt"]=evt.target.parentNode.parentNode.getAttribute('href');
			}
		}else{
			flag = evt.target.parentNode.getAttribute('index');
			params["cnt"]=evt.target.parentNode.getAttribute('href');
		}
	}else{
		flag = evt.target.getAttribute('index');
		params["cnt"]=evt.target.getAttribute('href');
	}
	var btnTagId = btnTag+"_"+flag;
	var obj = ["__NEWUA__",btnTagId,label];
	params["pos"]=flag;
	params["pgn"]="商城";
	params["url"]=window.location.href;
	obj.push(params);
	return obj;
}
function clickList1(evt, target){
    var flag=evt.target.getAttribute('index');
    return ['__NEWUA__', flag];
}
function clickBtnOrLink(evt, target,btnTag, label){
	return ['__NEWUA__', btnTag, label, {}, 0];
}
window.Avatar=window.Avatar||[];

